import service from "@/service/http.interceptor";
import store from '@/store'
import {baseUrl} from '@/common/const.js'

/**
 * 图片上传
 */
export const uploadImage = (filePath) => {
	return new Promise((resolve, reject)=>{
		let basePath = baseUrl
		const token = store.getters.accessToken
		console.log(basePath)
		uni.uploadFile({
			url:`${basePath}/admin/sys-file/upload`,
			filePath: filePath,
			name: 'file',
			file: filePath,
			header:{
				Authorization: token
			},
			success: result=>{
				// 返回服务器路径
				const data = JSON.parse(result.data)
				resolve(data.data)
			},
			fail: error => {
				reject(error)
			}
		})
	})
}